<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <title>
		上架下架管理
	</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css"  />
</head>
<script src="${pageContext.request.contextPath}/js/jquery-1.6.3.js"></script>
 <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
/*上下架按钮方法*/
$(".shelvesbtn").click(function(){
	var state=${shelves};
	if(state==1){
	state=0;
	}else{
	state=1;
	}
	var id=$(this).find("input").val();
	var url="${pageContext.request.contextPath}/commodity/updateShelves.action";
	$.post(url,{"id":id,"shelves":state},function(data){
		if(data.result==null){
		alert(操作失败请刷新);
		}else{
		$("#commodity"+id).css("display","none");
		}
	});
});
$("#search").click(function(){
		if($("#searchcontent").val()==null||$("#searchcontent").val()==""){
			alert("请填写搜索关键字");
			return false;
		}
});
});
</script>
<body style="width: 100%;height: 100%">
    	<div style="width: 100%;height: 70px;border-bottom: 1px solid #00EEEE;background:#009ACD">
    		<a href="${pageContext.request.contextPath}/commodity/listShelves.action?shelves=1" style="color:inherit">
    		<div id="noShelves" style="width:50%;float:left;text-align: center;" ><h3>未上架商品</h3></div>
    		</a>
    		<a href="${pageContext.request.contextPath}/commodity/listShelves.action?shelves=0" style="color:inherit">
    		<div id="isShelves" style="width:50%;float:left;text-align: center;"><h3>已上架商品</h3></div>
    		</a>
    	</div>
    	<div style="margin-left: 70%">
    		<form action="${pageContext.request.contextPath}/commodity/searchComm.action" method="post">
    		<input id="searchcontent" type="text" style="border:1px solid #FF7F00" placeholder="商品标题或品牌" name="search">
    		<input type="hidden" value="3" name="bs">
    		<input id="search" type="submit" value="搜索" style="background: #FF7F00;color:#fff;height: 30px;">
    		</form>
    	</div>
    	<div style="width:200px;margin:auto" id="shelvesState">
    	<c:if test="${shelves=='1'}">
    	<span style="font-size: 16px">未上架商品</span>
    	</c:if>
    	<c:if test="${shelves=='0'}">
    	<span style="font-size: 16px">已上架商品</span>
    	</c:if>
    	</div>
    	<c:if test="${commodity!=null }">
    	<c:forEach items="${commodity }" var="comm">
    	<div class="commodity" id="commodity${comm.id }" >
    		<img src="${pageContext.request.contextPath}/file/img/${comm.titleimg }" >
    		<div style="width:400px;height:100px;margin-left: 10px;margin-top:10px;float: left">
    			<span style="font-size: 16px;font-weight: 600">商品名称:${comm.title }</span>
    			<br><span style="font-size: 16px;font-weight: 600">商品价格:${comm.price }</span>
    			<br><span style="font-size: 16px;font-weight: 600">创建时间:
    			<fmt:formatDate value="${comm.cdate }" pattern="yyyy-MM-dd HH:mm:ss"/></span>
    			<br><span style="font-size: 16px;font-weight: 600">商品类型:${comm.categoryid }</span>
    		</div>
    		<div style="width:300px;height:100px;margin-left: 10px;margin-top:10px;float: left">
    			<span style="font-size: 16px;font-weight: 600">商品品牌:${comm.brand }</span>
    			<br><span style="font-size: 16px;font-weight: 600">商品库存:${comm.stock }</span>
    			<br><span style="font-size: 16px;font-weight: 600">是否上架:
    			<c:if test="${comm.shelves==0 }">已上架</c:if>
    			<c:if test="${comm.shelves==1 }">未上架</c:if>
    			</span>
    		</div>
    		<div class="shelvesbtn" >
    		<input type="hidden" value="${comm.id}">
    	<c:if test="${comm.shelves==1}">
    		<span style="font-size: 20px;color:#fff;">上<br><br>架</span>
    	</c:if>
    	<c:if test="${comm.shelves==0 }">
    		<span style="font-size: 20px;color:#fff;">下<br><br>架</span>
    	</c:if>
    		
    		</div>
    	</div>
    	</c:forEach>
    	</c:if>
    	<c:if test="${commodity==null }">
    		<h3 style="margin-left: 43%">没有找到商品</h3>
    	</c:if>
    	<c:if test="${commodity!=null }">
    			   <!-- 翻页 -->
	      <div style="margin-left: 72%;margin-top: 3%">
	      		<a style="color:#FF7F00" href="${pageContext.request.contextPath}/commodity/listShelves.action?page=${page-1}&shelves=${shelves}">上一页</a>
	      		当前第<span style="color:#FF7F00">${page+1}</span>页
	      		<a style="color:#FF7F00" href="${pageContext.request.contextPath}/commodity/listShelves.action?page=${page+1}&shelves=${shelves}">下一页</a>
	      </div>
    	</c:if>
 </body>
   <style>
   #isShelves:hover{
   background: #00EEEE;cursor: pointer;height:100%;
   }
   #noShelves:hover{
   background: #00EEEE;cursor: pointer;height:100%;
   }
  .commodity{
		height: 120px;
		width:950px;
		border:1px solid #FF7F00;
		margin:10px auto;
  }
  .commodity img{
  height:98px;width:98px;margin-top: 10px;margin-left: 5px;
  border: 1px solid #FF7F00;float:left;
  }
  .shelvesbtn{
  width:70px;height:120px;float: left;
  background: #FF7F00;text-align: center;margin-left:55px;
  padding-top: 10px;
  }
    .shelvesbtn:HOVER{
  background: #FF0000;cursor: pointer;
  }
   </style>
</html>